<template>
    <div class="customNavBar">
      <!-- :class="changeHerightJst? myHeight : ''"  -->
      <van-nav-bar
       :style="{'paddingTop': myHeight}"
       :left-text = leftTetx :title = titleTest :taskCode="taskCode" :face="face" :isYQX="isYQX" fixed :border=false left-arrow @click-left="onClickLeft">
        <template #right>
          <slot name="rightContent"></slot>
        </template>
      </van-nav-bar>
    </div>
</template>


<script setup lang="ts">
  import { JSONStringify } from "lib/tool";
import { onMounted ,ref} from "vue"
  import { useRouter } from 'vue-router';
  import { Toast } from '/@/utils/Message';
  const router = useRouter();
  const props = defineProps({
    leftTetx: {
      type: String,
      default: false,
    },
    titleTest:{
      type: String,
      default: false, 
    },
    isYQX: {
      type: String,
     default:'0', 
    },
    face: {
      type: String || Boolean,
      default:'',
    },
    H5: {
      type: String || Boolean,
      default:'',
    },
    taskCode: {
      type: String,

    }
  });
  const myHeight = ref<any>('')
  const realHeight = ref<Number>(60)
  onMounted(() => {
    // console.log(changeHerightJst.value)
    // console.log(props.titleTest)
    // let c = sessionStorage.getItem("jstHeaderHeight")?sessionStorage.getItem("jstHeaderHeight"):'20'
    myHeight.value = sessionStorage.getItem("jstHeaderHeight")?JSON.parse(sessionStorage.getItem("jstHeaderHeight")):''
    console.log(myHeight.value)
  });
  const emits = defineEmits(['goBack'])
  const goBack = () => {
    emits('goBack')
}
const onClickLeft = () => {
  if(router.currentRoute.value.name == 'WorkTable'){
      router.push({ path: '/login'}) 
    } else {
      if (props.isYQX == '1' || props.face  ) {
        window.history.go(-1);
      } else if(props.H5){
        //如果需要父组件自定义方法，需要传H5参数
        goBack()
      }else{
        router.go(-1)
      }
    }
  }
  </script>


  <style lang="less" scoped>
    .customNavBar {
      position: sticky;  
       background-color:rgba(250,250,250,0);
    }

    .van-nav-bar {
        padding-top: 17px;
        height: 44px;
        background-color:rgba(250,250,250,0);
    }

    :deep(.van-ellipsis){
      color:none;
    }

    :deep(.van-nav-bar__title){
      color:#222222;
      font-size: 16px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
    }

  
    :deep(.van-icon) {
        color:black;
    }

    :deep(.van-nav-bar__text ){
        color: black;
    }

     //标题字体大小
    :deep(.van-ellipsis) {
        color: black;
        //font-size: 2rem;
    }

  </style>
  
  